<!-- Edit Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Edit</h4>
      </div>
      <div class="modal-body">

        <form role="form" id="form-edit" action="" method="post">

          <div class="form-group">
            <label for="categoryid">CategoryId:</label>
            <input type="text" name="categoryid" class="form-control" />
          </div>

          <div class="form-group">
            <label for="categoryid">Name:</label>
            <input type="text" name="categoryname" class="form-control" />
          </div>

        </form>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
        <button type="button" id="submit-edit" class="btn btn-primary">Save</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script type="text/javascript">

    /*Form edit*/
   $('.btn-edit').click(function()
    {
      // get id edit
      var idEdit = $(this).closest('tr').prop('id');
      var categoryname = $(this).closest('tr').find('td:eq(0)').text();

      // set value for input
      $("input[type='text'][name='categoryid']").val(idEdit);
      $("input[type='text'][name='categoryname']").val(categoryname);

      // btn-edit click
      $('#submit-edit').click(function(event) 
      {
        // set action for form edit
        $('#form-edit').attr('action', '<?php echo base_url(); ?>/index.php/category_controller/update/' + idEdit);
        // submit form
        $('#form-edit').submit();
      });
    });

</script>